package com.example.demo.Controller;

import com.example.demo.Mapper.BlogMapper;
import com.example.demo.Mapper.CustomerMapper;
import com.example.demo.Mapper.GsdtMapper;
import com.example.demo.Mapper.UserMapper;
import com.example.demo.Service.BlogService;
import com.example.demo.Service.BlogServiceImpl;
import com.example.demo.pojo.Blog;
import com.example.demo.pojo.Customer;
import com.example.demo.pojo.User;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Random;

@Controller
public class HomeController {
    @Autowired
    private BlogServiceImpl mapper;
    @Autowired
    private GsdtMapper gsdtMapper;
    @Autowired
    private CustomerMapper customerMapper;
    @GetMapping("/")
    public String Index(Model model){
        List<Blog> blogList = mapper.listBlogTopTen();
        model.addAttribute("blog",blogList);
        model.addAttribute("gsdt",gsdtMapper.getGsdtlistTop10());
        return "Index";
    }
    @GetMapping("/admin/Login")
    public String Login(){
        return "admin/Login";
    }
    @GetMapping("/about")
    public String about(){
        return "about";
    }
    @GetMapping("/admin/product/{id}")
    public String adminProduct(@PathVariable Integer id,Model model){
        model.addAttribute("blog",mapper.selectBlogById(id));
        return "blog-product";
    }
    @GetMapping("/zhaoping")
    public String zhaoping(){
        return "zhaoping";
    }
}
